


VERSION =1.0.0

#  to print the debug messages to syslog)
DPL_DEBUG = false	

# to build any of the extras programs pass:
#  make EXTRAS="extras/<extra1> extras/<extra2>"
EXTRAS =	\
			lib \
			lib/dpl/tools \
			
	
TARGET_BIN=	dpl.elf	
			
			
# make the build silent
V =

ifeq ($(strip $(V)),)
	E = @echo
	Q = @
else
	E = @\#
	Q =	
endif
export E Q

ifndef NFS_ROOT_DIR
NFS_ROOT_DIR:=/tftpboot
endif

PROJECT_ROOT:=$(PWD)
export PROJECT_ROOT

all: check_env 
	#$(MAKE) tests -C mapi/build 
	#$(MAKE) install -C mapi/build 
	$(Q) extras="$(EXTRAS)"; for target in $$extras; do \
	$(MAKE) \
		-C $$target $@ || exit 1; \
	done;

clean:
	$(E) "  CLEAN   "
	$(Q) extras="$(EXTRAS)"; for target in $$extras; do \
	$(MAKE) clean \
		-C $$target $@ || exit 1; \
	done;
clean-all:
	$(E) "  CLEAN   "
	$(Q) - find . -type f -name '*.orig' -print0 | xargs -0r rm -f
	$(Q) - find . -type f -name '*.rej' -print0 | xargs -0r rm -f
	$(Q) - find . -type f -name '*~' -print0 | xargs -0r rm -f
	$(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0r rm -f
	$(Q) - find . -type f -name "*.gcno" -print0 | xargs -0r rm -f
	$(Q) - find . -type f -name "*.gcda" -print0 | xargs -0r rm -f
	$(Q) - find . -type f -name "*.gcov" -print0 | xargs -0r rm -f
	@ extras="$(EXTRAS)"; for target in $$extras; do \
		$(MAKE) -C $$target $@ || exit 1; \
	done;
	 

install:all
	#$(Q) cp mapi/bin/libmapi.so $(NFS_ROOT_DIR)


	



.PHONY: check_env0  all clean install 
check_env:
	$(E) "CHECK_ENV"
check_env0:
ifndef REFSW 
	$(error REFSW is not set)
	$(E) "Run source env.src then try again!"
endif
ifndef LINUX
	$(error LINUX is not set)
	$(E) "Run source env.src then try again!"
endif
ifndef NFS_ROOT_DIR
	$(info PLEASE set NFS_ROOT_DIR in your env.src,default is /tftpboot)
	@read
endif
